package com.example.selfproperties;

import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.URL;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 对于复杂的配置或嵌套的kv,我们可以编写自定义结构属性以更好的方式进行管理。
 */

//prefix设置key的前缀;
@ConfigurationProperties(prefix = "com.kfit.company")
@Component
public class Prop8 {

    @URL
    private String url;
/*
    Property: com.kfit.company.url
    Value: kfit
    Reason: 需要是一个合法的URL
*/

//    @Max(value = 99)
    @Max(value = 1000)
    @Min(value = 1)
    private int employCount;

  /*  Property: com.kfit.company.employCount
    Value: 100
    Reason: 最大不能超过99*/

    @NotNull
    private String name;

    @NotEmpty
    private String location;


  /*  Property: com.kfit.name
    Value: null
    Reason: 不能为null

    Property: com.kfit.location
    Value: null
    Reason: 不能为空
    */

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getEmployCount() {
        return employCount;
    }

    public void setEmployCount(int employCount) {
        this.employCount = employCount;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }
}
